package com.woniu.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniu.entity.HouseInfo;
import com.woniu.mapper.HouseInfoMapper;
import com.woniu.service.HouseInfoService;
import com.woniu.uitls.ResponseUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class HouseInfoServiceImpl1 implements HouseInfoService {
    @Resource
    private HouseInfoMapper houseInfoMapper;
    @Override
    public ResponseUtil findAll(Integer pageNum, Integer pageSize, Long typeId) {
        PageHelper.startPage(pageNum,pageSize);
        if (typeId == 0){
            typeId = null;
        }
        List<HouseInfo> all = houseInfoMapper.findAll(typeId);

        System.out.println(all);
        PageInfo pageInfo = new PageInfo(all);
        return ResponseUtil.get(200,"分页成功",pageInfo);
    }

    @Override
    public ResponseUtil findById(Long houseId) {
        HouseInfo byId = houseInfoMapper.findById(houseId);
        return ResponseUtil.get(200,"成功",byId);
    }

    @Override
    public Integer add(HouseInfo houseInfo) {
        return houseInfoMapper.add(houseInfo);

    }

    @Override
    public Integer update(HouseInfo houseInfo) {
        return houseInfoMapper.update(houseInfo);
    }

    @Override
    public Integer delete(Integer houseId) {
        return houseInfoMapper.delete(houseId);
    }
}
